<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        body{
            background-color: brown;
        }
        .box{
            width:600px;
            height: 100%;
            margin: 0 auto;
            transform: translate(5%,800%);
        }
        h2{
            color: white;
            
        }
    </style>
</head>

<body>
    <div class="box">
        <h2></h2>
    </div>
    <script>
        let h2 = document.querySelector("h2")
        function tim() {
            let date1 = new Date()
            let date2 = new Date('2026-01-01 00:00:00')
            let t1 = date1.getTime()
            let t2 = date2.getTime()
            t3 = t2 - t1
            let a = t3 / 86400000
            let day = Math.floor(t3 / 86400000)
            // console.log(day,a);
            
            // let h5 = a - day
            let h6 = (a - day) * 24
            let h = Math.floor(h6) < 10 ? "0" + Math.floor(h6) : Math.floor(h6)
            // let minu1 = h6 - h
            let minu2 = (h6 - h) * 60
            let minu = Math.floor(minu2) < 10 ? "0" + Math.floor(minu2) : Math.floor(minu2)
            let s1 = minu2 - minu
            let s = Math.floor(s1 * 60) < 10 ? "0" + Math.floor(s1 * 60) : Math.floor(s1 * 60)
            let str = `距离2026年新年倒计时${day}天${h}小时${minu}分钟${s}秒`
            h2.innerHTML = str

        }
        tim()
        setInterval(tim,1000)
        
        // Math.floor(and/1000%60)//秒
        // Math.floor(and/1000/60%60)//分
        // Math.floor(and/1000/60/60%24)//时
        // Math.floor(and/1000/60/60/24)//天




    </script>
</body>

</html>